package com.hrpc.channelHandler;

import com.hrpc.channelHandler.handler.MySimpleChannelInboundHandler;
import com.hrpc.channelHandler.handler.hRpcRequestEncoder;
import com.hrpc.channelHandler.handler.hRpcResponseDecoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

public class ClientChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //处理器piplane
        //netty自带的日志处理器
        socketChannel.pipeline()
                //netty自带的日志处理器
                .addLast(new LoggingHandler(LogLevel.DEBUG))
                //消息编码器
                .addLast(new hRpcRequestEncoder())
                //入站的解码器
                .addLast(new hRpcResponseDecoder())
                //处理结果
                .addLast(new MySimpleChannelInboundHandler());
    }
}
